//
//  ViewController.m
//  YSVideoPlayer
//
//  Created by Apple on 2020/7/19.
//  Copyright © 2020 Apple. All rights reserved.
//

#import "ViewController.h"
#import "KyleJAVPlayerView.h"

@interface ViewController ()
<
AVPlayerUpdateDelegate
>

/// YSAVPlayerView
@property (nonatomic, strong) KyleJAVPlayerView *playerView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.playerView = ({
        KyleJAVPlayerView *player = [[KyleJAVPlayerView alloc] initWithFrame:CGRectMake(0, 88, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-88-83)];
        player.delegate = self;
        player;
    });
    NSString *url = @"http://vod.yuelvdaren.com/7a51ef8c22d8432fa908c116a6206120/7eec0256e5754ab48a4d217f3899cc3d-c2ababbd8f9106ffd929ba095408f7da-sd.mp4";
    [self.playerView setPlayerWithUrl:url];
    [self.view addSubview:self.playerView];
}

//播放进度更新回调方法
- (void)onProgressUpdate:(CGFloat)current total:(CGFloat)total {
    
    NSLog(@"onProgressUpdate:%f total:%f", current, total);
}

//播放状态更新回调方法
- (void)onPlayItemStatusUpdate:(AVPlayerItemStatus)status {

    NSLog(@"onPlayItemStatusUpdate:%ld", (long)status);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    [super touchesBegan:touches withEvent:event];
    
    [self.playerView updatePlayerState];
}

@end
